/*
 * @(#)MaintFormRoutingRuleForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.form.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.form.bean.FormElement;
import com.dcivision.form.bean.FormRoutingRule;
import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;

/**
  MaintFormRoutingRuleForm.java

  This class is the for web form purpose.

  @author      Vera Wang
  @company     DCIVision Limited
  @creation date   16/05/2005
  @version     $Revision: 1.3 $
*/

public class MaintFormRoutingRuleForm extends AbstractActionForm {

  public static final String REVISION = "$Revision: 1.3 $";

  private String formRecordID = null;
  private String ruleName = null;
  private String ruleType = FormRoutingRule.ROUTING_TYPE_VERIFY;
  private String checkRule = null;
  private String operationType = null;
  private Object formEquation = null;
  private Object formOperationEquation = null;
  private String targetElementID = null;
  
  private FormElement formElement = null;
  private String formElementStr = null;
  private String operand = null;
  private String value = null;
  private String formEquationListValue = null;
  private String formEquationItem = null;
  private String routeNameListValue = null;
  private String optionElementIDs = null;

  public MaintFormRoutingRuleForm() {
    super();
  }

  public String getFormRecordID(){
    return this.formRecordID;
  }
  
  public void setFormRecordID(String formRecordID){
    this.formRecordID = formRecordID;
  }
    
  public String getRuleName() { 
    return(this.ruleName);
  }

  public void setRuleName(String ruleName) { 
    this.ruleName = ruleName;
  }

  public String getRuleType() { 
    return(this.ruleType);
  }

  public void setRuleType(String ruleType) { 
    this.ruleType = ruleType;
  }

  public String getCheckRule() {
    return checkRule;
  }
  
  public void setCheckRule(String checkRule) {
    this.checkRule = checkRule;
  }
  
  public String getOperationType() { 
    return(this.operationType);
  }

  public void setOperationType(String operationType) { 
    this.operationType = operationType;
  }

  public Object getFormEquation() { 
    return(this.formEquation);
  }

  public void setFormEquation(Object formEquation) { 
    this.formEquation = formEquation;
  }

  public Object getFormOperationEquation() { 
    return(this.formOperationEquation);
  }

  public void setFormOperationEquation(Object formOperationEquation) { 
    this.formOperationEquation = formOperationEquation;
  }

  public String getTargetElementID() { 
    return(this.targetElementID);
  }

  public void setTargetElementID(String targetElementID) { 
    this.targetElementID = targetElementID;
  }
  
  public FormElement getFormElement(){
    return this.formElement;
  }
  
  public void setFormElement(FormElement formElement){
    this.formElement = formElement;
  }
  
  public String getFormElementStr(){
    return this.formElementStr;
  }
  
  public void setFormElementStr(String formElementStr){
    this.formElementStr = formElementStr;
  }
  
  public String getOperand(){
    return this.operand;
  }
  
  public void setOperand(String operand){
    this.operand = operand;
  }
  
  public String getValue(){
    return this.value;
  }
  
  public void setValue(String value){
    this.value = value;
  }
  
  public String getFormEquationListValue(){
    return this.formEquationListValue;
  }
  
  public void setFormEquationListValue(String formEquationListValue){
    this.formEquationListValue = formEquationListValue; 
  }
  
  public String getFormEquationItem(){
    return this.formEquationItem;    
  }
  
  public void setFormEquationItem(String formEquationItem){
    this.formEquationItem = formEquationItem; 
  }
  
  public String getRouteNameListValue(){
    return this.routeNameListValue; 
  }
  
  public void setRouteNameListValue(String routeNameListValue){
    this.routeNameListValue = routeNameListValue; 
  }
  
  public String getOptionElementIDs() {
    return optionElementIDs;
  }
    
  public void setOptionElementIDs(String optionElementIDs) {
    this.optionElementIDs = optionElementIDs;
  }
  
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }
  
  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setFormRecordID(null);
    this.setRuleName(null);
    this.setRuleType(this.ruleType);
    this.setCheckRule(null);
    this.setOperationType(null);
    this.setFormEquation(null);
    this.setFormOperationEquation(null);
    this.setTargetElementID(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    FormRoutingRule tmpFormRoutingRule = new FormRoutingRule();
    tmpFormRoutingRule.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpFormRoutingRule.setFormRecordID(TextUtility.parseIntegerObj(this.getFormRecordID()));
    tmpFormRoutingRule.setRuleName(this.getRuleName());
    tmpFormRoutingRule.setRuleType(this.getRuleType());
    tmpFormRoutingRule.setCheckRule(this.getCheckRule());
    tmpFormRoutingRule.setOperationType(this.getOperationType());
    tmpFormRoutingRule.setFormEquation(this.getFormEquation());
    tmpFormRoutingRule.setFormOperationEquation(this.getFormOperationEquation());
    tmpFormRoutingRule.setTargetElementID(this.getTargetElementID());
    tmpFormRoutingRule.setRecordStatus(this.getRecordStatus());
    tmpFormRoutingRule.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpFormRoutingRule.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpFormRoutingRule.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpFormRoutingRule.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpFormRoutingRule.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpFormRoutingRule;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    FormRoutingRule tmpFormRoutingRule = (FormRoutingRule)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpFormRoutingRule.getID()));
    this.setFormRecordID(TextUtility.formatIntegerObj(tmpFormRoutingRule.getFormRecordID()));
    this.setRuleName(tmpFormRoutingRule.getRuleName());
    this.setRuleType(tmpFormRoutingRule.getRuleType());
    this.setCheckRule(tmpFormRoutingRule.getCheckRule());
    this.setOperationType(tmpFormRoutingRule.getOperationType());
    this.setFormEquation(tmpFormRoutingRule.getFormEquation());
    this.setFormOperationEquation(tmpFormRoutingRule.getFormOperationEquation());
    this.setTargetElementID(tmpFormRoutingRule.getTargetElementID());
    this.setRecordStatus(tmpFormRoutingRule.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpFormRoutingRule.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpFormRoutingRule.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpFormRoutingRule.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpFormRoutingRule.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpFormRoutingRule.getUpdateDate()));
  }
}
